
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet"type="text/css"href="css/css.css">
        <title>Pages</title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <body id ="background">
        <div id ="banner"> 

        </div>
        <div id ="menu1">
            <ul id="s">
                <li><a href ="#">Home</a></li>
                <li><a href ="#">About</a></li>
                <li><a href ="#">Forums</a></li>
                <li><a href ="#">Contact Us</a></li>
                <li style="float: right"><a href ="http://localhost/hhhai-web2/login.php?page=1">Login</a></li>
            </ul>
        </div>
        <div id="menu2">
            <div class="login">  

                <?php
                if (isset($_GET["logout"]) && $_GET["logout"] == true) {
                    unset($_SESSION["id"]);
                    header("location:login.php");
                }
                ?>
                <?php require_once '/model/db.php'; ?>
                <?php
                require_once '/class/pagination.php';
                require_once './model/user.php';
                require_once './model/works.php';
                 
                $wordss = new pagination();
                $work1 = new DB();
                $outt = $work1->select1();
               
                $ptrang = $wordss->Phantrang();
                 $wotk = new Works();
                 $count =$wotk->countWords();
                 $count ->table_name = "works";
                ?>

                <?php
                if (!isset($_GET["page"]))
                    $page = 1;
                else
                    $page = $_GET["page"];

                $total = $count->countWords();
                ?>
                <div id="dangnhap">
                    <from method ="POST">

                        <link rel="slintylesheet" type="text/css" href="./public/css/style.css">

                        <p><div class="page-form">
                            <div class="login-form">


                                <p><form id="login"  method="post">

                                    <p> UserName <input name="username" type="text">


                                    <p> Password  <input name="password" type="password">

                                    <p><input id="submit"   name="submit"   type="submit" value="Log in">

                                </form>
                            </div>

                        </div>
                        <a href="End.php">Log out</a>
                        <?php
                        if (isset($_POST['submit']))
                            :
                            ?>
                            <?php
                            $username = $_POST['username'];
                            $password = $_POST['password'];
                            $isOk = FALSE;
                            $index = -1;
                            for ($i = 0; $i < count($users); $i++) {
                                if ((strcmp($users[$i]['username'], $username) == 0) &&
                                        (strcmp($users[$i]['password'], $password) == 0)) {
                                    $isOk = TRUE;
                                    $index = $i;
                                }
                            }
                            if ($isOk) {
                                $_SESSION["id"] = $users[$index]["id"];
                                header("Location: http://localhost/hhhai-web2/public/index.php?uid=" . $users[$index]['id']);
                            } else {
                                echo 'Fail';
                            }
                            ?>
                        <?php endif; ?>
                </div>
            </div>
        </div>

    </body>
    <a href="index.php" >Log uot</a>


    <div id ="body">
        <?php
        if (isset($_GET["logout"]) && $_GET["logout"] == true) {
            unset($_SESSION["id"]);
            header("location:login.php");
        }
        ?>


    </div>





</html>



